//继承模板
{extend name="public/base"}


//CSS
{block name="style"}
<link rel="stylesheet" href="__ADMIN_STATIC__/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
{/block}


{block name="breadcrumb" title="当前位置"}{/block}

//正文区域
{block name="body"}{//---------------------------------------------------------------------------}
<div class="page-container">
    <form action="/admin/config/save.html" method="post" class="form form-horizontal" id="form1">
        <div id="tab-category" class="HuiTab">
            <div class="tabBar cl">


{//volist name="['edit'=>'基本信息' ,'role'=>'部门岗位' ,'rule'=>'权限信息' ]" id="item"}
{volist name="['edit'=>'基本信息' ,'role'=>'部门岗位']" id="item"}

        {if condition=" ( $info.user_id   ||  request()->action() ==   $key) "}
                <span {if condition="request()->action() eq $key"}class="current"{/if}>

                    <a href="{:url($key,['id'=>$info.user_id])}">{$item}</a>
                </span>
        {else/}
                <span style="color:#cccccc;">
                    {$item}
                </span>

        {/if}
{/volist}

            </div>






            <div class="tabCon"  id="部门岗位" style=" display:block;">

        <fieldset><legend>部门岗位</legend>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>部门(岗位)：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <span class="select-box">
                <select class="select" name="id" id="select_role">
                    {:model('Role')->tree_options()}
                </select>
                </span>
            </div>
            <div class="formControls col-xs-8 col-sm-2">
                <button class="btn btn-primary radius " type="button" id="btn_add" >&nbsp;<i class="icon Hui-iconfont">&#xe600;</i> 添加&nbsp;&nbsp;</button>
            </div>
        </div>

        </fieldset>
<br/>
    <form class="Huiform" method="get" action="" id="listForm">
    <table class="table table-border table-bordered table-bg table-tr-hover">
        <thead>
            <tr class="text-c">
                <th width="25">
                    <input type="checkbox" name="" value="">
                </th>
                <th class="text-l">部门(职位)</th>

                <th width="100">操作</th>
            </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
            <tr class="text-c">
                <td><input type="checkbox" value="100" name="id[{$vo.id}]"/> </td>
                <td>{$vo.role_place}</td>
                <td>
                <button onClick="list_del(this,{$vo.user_id},{$vo.id})" type="button" class="btn btn-danger size-MINI radius" title="删除">
                    <i class="Hui-iconfont">&#xe6e2;</i> 删除
                </button>
                </td>
            </tr>
        {/volist}
        </tbody>
    </table>
    </form>

            </div>
        </div>
        
    </form>
</div>




{/block}
//-----------------------------------------------------------------------------------------------


<!--请在下方写此页面业务相关的脚本-->
//-----------------------------------------------------------------------------------------------
{block name="script"}

<script type="text/javascript">




var del_url ='{:url('delUserRole')}';
/*行内(tr)内点击删除*/
function list_del(obj,user_id,role_id){
    layer.confirm('确认要【删除】吗？',function(index){
        $.ajax({
            type: 'POST',
            url: del_url,
            data:{user_id:user_id,role_id:role_id},
            dataType: 'json',
            success: function(d){
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:1000});
            },
            error:function(d) {
                console.log(d.msg);
            },
        });     
    });
}

//--------------------------------------------
$(function(){

    var user_id ="{$info.user_id}";
    var url_add_user_role = '{:url('addUserRole')}';
    
    var select_role = $('#select_role');
    var btn_add = $('#btn_add');



    //点击添加按钮 user_id  role_id  插入数据
    btn_add.on('click',function(){
        var role_id =  select_role.val();
        if( !role_id ){jBox.tip('岗位为空，添加错误') ;return false;}
        $.ajax({
            url: url_add_user_role ,
            type:'get' , // get post
            data: {user_id : user_id , role_id:role_id } , 
            dataType : 'html' ,
            success:function(d){
               console.log(d);
               location.reload();
            }
        });
    })
    



});



</script>

<style>
    

    
</style>



{/block}{//---------------------------------------------------------------------------}